package com.capgemini.remind.service;

import com.capgemini.remind.mapper.CommonsMapper;
import com.capgemini.remind.pojo.CodeValue;
import com.capgemini.remind.pojo.DealerInfo;
import com.capgemini.remind.pojo.OrderInfo;
import com.capgemini.remind.pojo.SmsTemplate;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 
 * @author
 * @date
 */
@Service
public class CommonsService {
	public final Logger log = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private CommonsMapper commonsMapper;


	public List<CodeValue> queryByCodeValueByType(String codeType) {
		return commonsMapper.queryByCodeValueByType(codeType);
	}
	public List<String> queryByCodeValueGroupByType(String codeType) {
		return commonsMapper.queryByCodeValueGroupByType(codeType);
	}

	public SmsTemplate queryBySmsTemplateByCode(String code){
		return commonsMapper.getBySmsTemplateByCode(code);
	}

	public DealerInfo getDealerInfoByDealerNum(String dealerNum){
		return commonsMapper.getDealerInfoByDealerNum(dealerNum);
	}

    public String getCodeValueByCodeTypeAndCode(String type, String code) {
        CodeValue cv = commonsMapper.queryByCodeValueByCode(type, code);
        if (null != cv)
            return cv.getCodeValue();
        return "";
    }

    /**
     * 获取短信是否发送标识
     * @return
     */
    public boolean isSendSMS(){
        String sendFlag = commonsMapper.getSendSmsFlag();

        return StringUtils.equals("1", sendFlag);
    }

    public int test() {
		return commonsMapper.test();
    }
    public List<OrderInfo> test1() {
		return commonsMapper.test1();
    }
}
